package xin.yangshuai.multithreading01;

import java.io.IOException;

/**
 * HelloController
 *
 * @author shuai
 * @date 2022/1/27
 */
public class HelloController {

    public static void main(String[] args) throws InterruptedException, IOException {

        StringBuilder builder = new StringBuilder();

        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int j = 0; j < 10000; j++) {
                    builder.append('a');
                }
            }
        });

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int j = 0; j < 10000; j++) {
                    builder.append('b');
                }
            }
        });

        System.out.println(t1.getPriority());
        System.out.println(t2.getPriority());

        t1.start();
        t2.start();

        try {
            t1.join();
            t2.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println(builder);
        System.out.println(builder.length());
    }
}
